<?php

import('com.yamvc.view.Mediator');
import("com.yado.DriverManager");
import("com.mysql.yado.MysqlDriver");
import("com.simpleApplication.events.MenuEvent");
import("com.mysql.yado.TableDescriptor");
import("com.mysql.yado.Table");
import("com.yamvc.utils.Utils");
import("com.simpleApplication.view.AuthPanelMediator");
class ApplicationMediator extends Mediator {
	/**
	 * Enter description here...
	 *
	 * @var IConnection
	 */
	private $_connection;
	public function __construct(ITemplate $template){
		//$this->_template=View::instance()->createRootTemplate("index");
		parent::__construct($template);
		$this->_template->putVariable("title","ApplicationMediator Title");
		$this->addEventListener(MenuEvent::ITEM_CLICK,new EventListener($this,"onItemClick"));
		/*$tpl=View::instance()->createTemplate("auth_panel");
		View::instance()->registerMediator("authPanelMediator",new AuthPanelMediator($tpl));
		$this->_template->putVariable("authPanel",$tpl);*/
		/*$this->_connection = DriverManager::getConnection($this->getConfig()->get("config.db.uri"));
		$decriptor = new TableDescriptor("users",$this->_connection);
		$user = new Table($decriptor);
		$user->init(1);
		var_dump($user->login);*/
		/*$stmt  = $this->_connection->prepearStatement("SELECT * FROM users;");
		$stmt->execute();
		$res = $stmt->getResultSet();
		while($r = $res->next()){
			var_dump($r);
		}*/
	}
	
	public function onItemClick(MenuEvent $event){
		//var_dump($event->getPlace());
		Utils::redirect($event->getPlace());
	}
}

?>